﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace T.FAS.Runtime.MF.Entity
{
    public class WorkflowInstanceDetail
    {
        [JsonProperty(PropertyName = "id")]
        public string RecordId { get; set; }
        [JsonProperty(PropertyName = "node_id")]
        public string ActivityId { get; set; }
        [JsonProperty(PropertyName = "title")]
        public string ActitiyName { get; set; }
     
        [JsonProperty(PropertyName = "status")]
        public string Status { get; set; }
        [JsonProperty(PropertyName = "elapsed_time")]
        public double? Duration { get; set; }
        [JsonProperty(PropertyName = "created_at")]
        public DateTime? StartTime { get; set; }
        [JsonProperty(PropertyName = "finished_at")]
        public DateTime? EndTime { get; set; }
        [JsonProperty(PropertyName = "node_type")]
        public string NodeType { get; set; }
        [JsonProperty(PropertyName = "error")]
        public string Exception { get; set; }
        [JsonProperty(PropertyName = "inputs")]
        public Dictionary<string,object> Inputs { get; set; }
        [JsonProperty(PropertyName = "outputs")]
        public Dictionary<string, object> Outputs { get; set; }
        [JsonProperty(PropertyName = "execution_metadata")]
        public ExecutionMetaData ExecutionMetaData { get; set; }
        [JsonProperty(PropertyName = "metadata")]
        public MetaData MetaData { get; set; }
    
        [JsonProperty(PropertyName = "parallel_id", NullValueHandling = NullValueHandling.Ignore)]
        public string ParallelID { get; set; }
        [JsonProperty(PropertyName = "parallel_start_node_id", NullValueHandling = NullValueHandling.Ignore)]
        public string ParallelStartNodeID { get; set; }
        [JsonProperty(PropertyName = "parent_parallel_id", NullValueHandling = NullValueHandling.Ignore)]
        public string ParentParallelID { get; set; }
        [JsonProperty(PropertyName = "parent_parallel_start_node_id", NullValueHandling = NullValueHandling.Ignore)]
        public string ParentParallelStartNodeID { get; set; }
        [JsonProperty(PropertyName = "index")]
        public int Index { get; set; }
    }

    public class ExecutionMetaData
    {
        [JsonProperty(PropertyName = "iteration_id",NullValueHandling = NullValueHandling.Ignore)]
        public string IterationID { get; set; }
        [JsonProperty(PropertyName = "iteration_index", NullValueHandling = NullValueHandling.Ignore)]
        public int? IterationIndex { get; set; }
        [JsonProperty(PropertyName = "parallel_id", NullValueHandling = NullValueHandling.Ignore)]
        public string ParallelID { get; set; }
        [JsonProperty(PropertyName = "parallel_start_node_id", NullValueHandling = NullValueHandling.Ignore)]
        public string ParallelStartNodeID { get; set; }
        [JsonProperty(PropertyName = "parent_parallel_id", NullValueHandling = NullValueHandling.Ignore)]
        public string ParentParallelID { get; set; }
        [JsonProperty(PropertyName = "parent_parallel_start_node_id", NullValueHandling = NullValueHandling.Ignore)]
        public string ParentParallelStartNodeID { get; set; }
    }

    public class MetaData
    {
        [JsonProperty(PropertyName = "iterator_length")]
        public int IteratorLength { get; set; }
        [JsonProperty(PropertyName = "iterator_index")]
        public int IteratorIndex { get; set; }
        [JsonProperty(PropertyName = "loop_length")]
        public int LoopLength { get; set; }
        [JsonProperty(PropertyName = "loop_index")]
        public int LoopIndex { get; set; }
    }
}
